/*
 * @Author: jiu yin
 * @Date: 2023-05-15 14:50:04
 * @LastEditTime: 2023-05-17 17:53:31
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \admin-react\src\redux\modules\common.ts
 * jiu
 */
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";

// 异步
export const asyncFn = createAsyncThunk("test", async (value: any) => {
   return Promise.resolve(value);
});

type commonType = {
    key:string,
    value:any
}

export const common = createSlice({
   name: "common",
   initialState: { i18n_lang: "zh"  },
   reducers: {
      set: (state, action: PayloadAction<commonType>) => {
         let { key, value } = action.payload;
         //@ts-ignore
         state[key] = value;
      },
   },
});

// Action creators are generated for each case reducer function
export const { set } = common.actions;

export default common.reducer;
